﻿using QLBH.DATA;
using QLBH.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QLBH.BUSINESS
{
    public class PhieuXuatBus
    {
        private static PhieuXuatData db = new PhieuXuatData();
        public static string MA_PX { set; get; }
        public static string ThemMoi(PHIEUXUATPARAM PHIEUXUAT)
        {
            if (db.ThemMoi(PHIEUXUAT))
            {
                MA_PX = db.Result;
                return "1";
            }
            else
                return db.Error;
        }

        public static List<PHIEU_XUAT> TimPhieuXuatTheoMa(string ma_phieu_Xuat, int tong_so_dong)
        {
            return db.TimPhieuXuatTheoMa(ma_phieu_Xuat, tong_so_dong);
        }

        public static List<PHIEU_XUAT> TimPhieuXuatTheoNgay(List<DateTime> ngay, int tong_so_dong)
        {
            var max = ngay.Max(p => p.Date);
            var min = ngay.Min(p => p.Date);
            return db.TimPhieuXuatTheoMa("", tong_so_dong).ToList().Where(p=>p.NGAY_XUAT.Date<=max && p.NGAY_XUAT.Date>=min).ToList();
        }

        public static List<PHIEU_XUAT> TimPhieuXuatTheoMa(string ma_phieu_Xuat)
        {
            return db.TimPhieuXuatTheoMa(ma_phieu_Xuat);
        }
    }
}